package com.sentrix.auto.printercenter.presentation.center.dto;

import com.sentrix.auto.printercenter.domain.entity.PrinterAgentEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Schema(description = "打印机代理信息")
@Data
public class AgentResDto {
    @Schema(description = "代理ID", type = "Long")
    private Long id;
    @Schema(description = "代理code")
    private String code;
    @Schema(description = "代理name")
    private String name;
    @Schema(description = "代理是否在线")
    private Boolean isOnline;
    @Schema(description = "代理连接时间")
    private Long gmtConnect;
    @Schema(description = "代理断开时间")
    private Long gmtDisconnect;
    @Schema(description = "sockent sessionId")
    private String sessionId;

    /**
     * 转换为DTO
     * @param entity
     * @return
     */
    public static AgentResDto fromDomain(PrinterAgentEntity entity) {
        AgentResDto dto = new AgentResDto();
        dto.setId(entity.getId());
        dto.setCode(entity.getCode());
        dto.setName(entity.getName());
        dto.setIsOnline(entity.getIsOnline());
        dto.setGmtConnect(entity.getGmtConnect());
        dto.setGmtDisconnect(entity.getGmtDisconnect());
        dto.setSessionId(entity.getSessionId());
        return dto;
    }
}
